/* is_fs_accessable - check whether exist directory named the fs_name in the uri,
 *                   and the superblock file in the directory (fs_name)
 * @param   uri       the place where is the filesystem palced
 * @param   fs_name   the directory named fs_name
 * @return  Return  the flag which check the directory and the superblock existed  
 */

bool
is_fs_accessable(char *uri, char *fs_name)
{
     DIR *dir, *dir1;
     struct dirent *ptr;
     int check = NO;                         //the return value
			 
     dir = opendir(uri);
	 if (dir == NULL)
     {
        perror("opendir error!");
	        return EDIR;
     }
						   
	while( (ptr = readdir(dir)) != NULL)
	{
         if( strcmp(ptr->d_name, fs_name) == 0)
         {
	            check = YES;
	            break;
		 }
    }
					     
	if(ptr == NULL)
	{
        printf("the directory is not exist!\n");
        return EDIR;
	}
									  
	dir1 = opendir(fs_name);
    if (dir1 == NULL)
	{
       perror("opendir error!");
       return EDIR;
	}
												
	while( (ptr = readir(dir1)) != NULL)
	{
        if( strcmp(ptr->d_name, "superblock.conf") == 0)
		{
			check = YES;
            break;
        }
	}
 
	if(ptr == NULL)
	{
       printf("the superblock.conf is not exist!\n");
  	   return EFILE;
	}
		
    closedir(dir1);
	closedir(dir);
		
	return check;
}

